from page import Page
from selenium.webdriver.common.by import By


class AddMoviePage(Page):

    @property
    def movie_name_field(self):
        return self.driver.find_element_by_name('name')

    @property
    def movie_year_field(self):
        return self.driver.find_element_by_name('year')

    @property
    def save_movie_button(self):
        return self.driver.find_element_by_xpath(".//a/img[@title='Save']")

    @property
    def is_this_page(self):
        return self.is_element_visible((By.XPATH, ".//h2[text()='Movie information']"))

    @property
    def year_error_label(self):
        return self.driver.find_element_by_xpath(".//label[@for='year']")